package 动态规划;

public class 盛最多水的容器 {

    public static int maxArea(int[] height) {
        int res = 0;
        int end = height.length - 1;
        if (end < 1){
            return 0;
        }
        int start = 0;
        while (start != end){
            int area = Math.min(height[start],height[end]) * (end - start);
            res = Math.max(res,area);
            if (height[start] > height[end]){
                end--;
            }else {
                start++;
            }
        }


        return res;
    }

    public static void main(String[] args) {
        int[] height = {1,2,1};
        System.out.println(maxArea(height));
    }
}
